<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>购物车</title>
    <script>
        function setType(itype) {
            document.getElementById("type").value = itype === 0 ? "" : "cls";
        }
    </script>
</head>
<body>
<form method="post" action="<c:url value="/Servlet6"/>">
    <input type="hidden" name="type" id="type" value=""/>
    <label for="sname">商品名</label>
    <input type="text" name="sname" id="sname"/> <br/>
    <label for="price">单价</label>
    <input type="text" name="price" id="price"/> <br/>
    <label for="num">数量</label>
    <input type="text" name="num" id="num"/> <br/>
    <input type="submit" value="生成" onclick="setType(0)"/>
    <input type="submit" value="清空" onclick="setType(1)"/>
</form>
<%--<form>--%>
<%--    <input type="hidden" name="type" value="cls"/> <br/>--%>
<%--    <input type="submit" value="清空"/>--%>
<%--</form>--%>
<br/>
<table border="1">
    <tr>
        <td>商品名</td>
        <td>单价</td>
        <td>数量</td>
    </tr>
    <c:forEach var="myproduct" items="${plist}">
        <tr>
            <td>${myproduct.sname}</td>
            <td>${myproduct.price}</td>
            <td>${myproduct.num}</td>
        </tr>
    </c:forEach>
    <tr>
        <td>总价：</td>
        <td colspan="2">${sum}</td>
    </tr>
</table>
</body>
</html>
